package com.kaijie.controller;

import java.util.Arrays;
import java.util.Map;

import com.kaijie.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kaijie.entity.ReserveInfnEntity;
import com.kaijie.service.ReserveInfnService;
import com.kaijie.utils.PageUtils;
import com.kaijie.utils.R;



/**
 * 
 *
 * @author Jy
 * @email 846021119@qq.com
 * @date 2022-02-28 12:02:21
 */
@RestController
@RequestMapping("kaijie/reserveinfn")
public class ReserveInfnController {
    @Autowired
    private ReserveInfnService reserveInfnService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("kaijie:reserveinfn:list")
    public R list(@RequestParam Map<String, Object> params){

        return R.ok().put("data", reserveInfnService.list());
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{rid}")
    @RequiresPermissions("kaijie:reserveinfn:info")
    public R info(@PathVariable("rid") Integer rid){
        ReserveInfnEntity reserveInfn = reserveInfnService.getById(rid);

        return R.ok().put("reserveInfn", reserveInfn);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("kaijie:reserveinfn:save")
    public R save(@RequestBody ReserveInfnEntity reserveInfn){
        reserveInfnService.save(reserveInfn);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("kaijie:reserveinfn:update")
    public R update(@RequestBody ReserveInfnEntity reserveInfn){
        ValidatorUtils.validateEntity(reserveInfn);
        reserveInfnService.updateById(reserveInfn);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("kaijie:reserveinfn:delete")
    public R delete(@RequestBody Integer[] rids){
        reserveInfnService.removeByIds(Arrays.asList(rids));

        return R.ok();
    }

}
